package top.younote.cherry.lambda;

import java.util.Calendar;
import java.util.GregorianCalendar;

/**
 * @Description:
 * @Author: duanyu
 * @CreateTime: 2022-06-04 08:32
 **/
public class Main {
    public static void main(String[] args) {
        System.out.println("hello world");
    }

    public static String printMonthCalendar(int year, int month) {
        if (year <= 0) return null;
        if (month <= 0) return null;
        if (month > 12) return null;
        //construct a calendar object, note that month must be 0-based.
        Calendar c = new GregorianCalendar(year, month - 1, 1);
        //get the number of days in that month
        int days = c.getActualMaximum(Calendar.DAY_OF_MONTH);
        //get the week day of first date in that month
        int weekday = c.get(Calendar.DAY_OF_WEEK);
        //print the headers
        System.out.println(Integer.toString(year) + "-" + Integer.toString(month));
        System.out.println("\tSun\tMon\tTue\tWed\tThu\tFri\tSat");
        //print space before the first day
        for (int i = 1; i < weekday; i++) {
            System.out.print("\t___");
        }
        //print the month calendar
        int week = weekday;
        for (int i = 1; i <= days; i++) {
            System.out.print("\t" + Integer.toString(i));
            week = (week + 1) % 8;
            if (week == 0) {//enter a new line
                System.out.println();
                week = 1; //first week day is Sunday (=1)
            }
        }
        return Integer.toString(days) + " days, " + weekday + "-th";
    }
}


